package demo3;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class AllCard {
    public static final String[] suits = {"♥", "♣", "♦", "♠"};
    public List<Card> cards = new ArrayList<>();

    public List<Card> buycard() {
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j < 14; j++) {
                Card card = new Card(suits[i], j);
                cards.add(card);
            }
        }
        return cards;
    }

    public void shuffle(List<Card> cards) {
        Random random = new Random();
        for (int i = 51; i > 0; i--) {
            int dex = random.nextInt(i);
            Card temp = cards.get(i);
            cards.set(i, cards.get(dex));
            cards.set(dex, temp);
        }
    }

    public void DrawCards() {
        List<List<Card>> hand = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cards.remove(0);
                List<Card> cards1 = hand.get(j);
                cards1.add(card);
            }
        }
        int j = 0;
        for (List<Card> cardList : hand) {
            System.out.println("第" + (++j) + "个人的牌:" + cardList);
        }
    }
}
